<template>
  <article class="page">
    <headerbar>添加红友</headerbar>
    <section class="frame-content-sub no-bg">

      <section class="inner-content pdv-9 pdh-4">

        <div class="people-info-wrap">
          <section class="people-info">
            <div class="avatar-img">
              <!--<img v-if="!redfriendsAdd.photo || redfriendsAdd.photo === ''" src="../../../../static/images/default.jpg" >-->
              <img :src="tools.getAvatarUrl(redfriendsAdd.userId)" >
            </div>
            <div class="text-wrap">
              <span class="name">{{redfriendsAdd.userName}}</span>
              <div class="tip">{{redfriendsAdd.groupName}}</div>
            </div>
          </section>
          <span class=""></span>
        </div>


        <section class="pdr-5">
          <section class="list-arrow">
            <div class="item pdt-1">
              <span class="title"></span>
            </div>
            <div class="item">
              <input placeholder="请输入申请理由" v-model="reason"></input>
            </div>
            <div class="item">
              <span class="title">来源</span>
              <span class="title">红友圈</span>
            </div>
          </section>
        </section>



        <div class="pdv-10"></div>
        <div class="pdv-10"></div>

        <div class="default-block-btn" v-preventReClick="1000" @click="addFriends($event)">添加红友</div>

        <div class="pdv-5"></div>
      </section>

    </section>
  </article>
</template>

<script>
  import tools from '@/utils/tools'
  import api from '@/common/config/api'
  import loginService from '@/service/loginService'
  import moment from 'moment'
  export default {
    name: 'redfriendsAdd',
    data () {
      return {
        reason: '',
        redfriendsAdd: {},
        userInfo: {}
      }
    },
    created () {
      this.userInfo = this.$localStorage.get('userInfo')
      this.redfriendsAdd = this.$store.state.redfriendsAdd
      console.log('--------------this.redfriendsAdd=', this.redfriendsAdd)
      console.log('--------------this.userInfo=', this.userInfo)
    },
    methods: {
      addFriends (e) {
       /* if (this.reason === '') {
          return tools.tip('请输入申请理由！')
        }*/
        if (e.target.disabled) {
          return false
        }
        let data = {
          applyUserId: this.userInfo.id,
          status: '0',
          friendId: this.redfriendsAdd.userId,
          applyReasion: this.reason
        }
        this.fetchService.friendApply(data).then(res => {
          if (res.code === 0) {
            tools.tip('申请成功')
            tools.back()
          } else {
            return tools.tip(res.message)
          }
        })
      },
      showImg (fileId) {
        let fileUrl = this.tools.getImgUrl(fileId)
        return fileUrl
      }
    }
  }
</script>

<style scoped lang="scss">

</style>
